package com.vancouver.knows.business.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.pangu.util.StringUtil;
import com.vancouver.knows.business.bean.DiscountInfo;

/**
 * 根据类型查询城惠列表解析
 * <p/>
 * Created by cxlin
 */
public class FetchCityDiscountsCategoryHandler extends ACheckableJsonParser {

	private List<DiscountInfo> discountInfoList;

	@Override
	protected void parserContent(JSONObject content) throws Exception {
		String posts = content.getString("posts");
		if (!StringUtil.isEmptyString(posts)) {
			discountInfoList = JSON.parseArray(posts, DiscountInfo.class);
		}

		if (discountInfoList == null) {
			discountInfoList = new ArrayList<DiscountInfo>();
		}
	}

	public List<DiscountInfo> getDiscountInfoList() {
		return discountInfoList;
	}

	@Override
	protected boolean isSuccess(int errorCode) {
		if (errorCode == 0 || errorCode == 6) {
			return true;
		}
		return false;
	}
}
